<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="com.feib.soeasy.util.CodeTableUtil"%>
<%@page import="com.feib.soeasy.model.Payment"%>


<script type="text/javascript">
<!--
$(document).ready(function() {
	
	$("[id^='viewPaymentImg-']").click(function() {
		var paymentPk = this.id.substring(15);
		doQueryPaymentsAction(paymentPk);
		
	});
	
});


//-->
</script>
	
<c:choose>
	<c:when test="${null != actionBean.queryResult && not empty actionBean.queryResult.paginatedList}">
		<table id="listTable">
			<thead>
				<tr>
					<th>繳費日期</th>
					<th>帳單名稱</th>
					<th>繳費帳號</th>
					<th>繳費金額</th>
					<th>繳費通路</th>
					<th>繳費狀態</th>
					<th>繳費明細</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${actionBean.queryResult.paginatedList}" var="viewObj" varStatus="rowstat">
				<tr>
					<td align="center"><fmt:formatDate value="${viewObj.payDue}" pattern="yyyy/MM/dd" /></td>
					<td><c:out value="${viewObj.paymentName}"/></td>
					<td><c:out value="${viewObj.virtualAccount}"/></td>
					<td align="right"><fmt:formatNumber value="${viewObj.totalAmount}" pattern="##,###" /></td>
					<td>
						<%
						Payment payment = (Payment)pageContext.getAttribute("viewObj");
						if (null != payment.getWriteOffPayment())
							out.println(CodeTableUtil.getInstance().getCodeName(CodeTableUtil.CODE_KIND_CHANNEL, payment.getWriteOffPayment().getChannel()));
						%>						
					</td>
					<td>
						<%
							if (1 == payment.getPaymentStatus().intValue() && 2 == payment.getPaymentStatus().intValue() && 3 == payment.getPaymentStatus().intValue())
								out.println(CodeTableUtil.getInstance().getCodeName(CodeTableUtil.CODE_KIND_PAYMENT_STATUS, "2"));
							else
							    out.println(CodeTableUtil.getInstance().getCodeName(CodeTableUtil.CODE_KIND_PAYMENT_STATUS, String.valueOf(payment.getPaymentStatus())));
						
						%>
						
					</td>
					<td>
						<div id="viewPaymentImg-<c:out value='${viewObj.paymentPk}'/>"><a href="javascript: void(0)" class="btnZoom">查詢</a></div>
												
					</td>
				</tr>
				</c:forEach>
				
				<tr>
					<td colspan="7" align="center">
						<input type="button" onclick="window.print();" value="列印畫面">
					</td>
				</tr>
			</tbody>
		</table>
		
	</c:when>
	<c:otherwise>
		<div id="queryNothingBlockDiv" style="display: none;">
			<c:out value="${actionBean.queryResult.message}"/>
		</div>	
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#queryNothingBlockDiv" ).dialog({  title:'學雜費繳費進度查詢' ,width: 600, resizable: false, modal: true, buttons : {
				Ok : function() {
					$(this).dialog("close");
				}
			}
			});
		});
		//-->
		</script>
		
	
	</c:otherwise>
</c:choose>
